<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('角色管理列表')" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>

                            <li>
                                <label>角色名：</label>
                                <input type="text" name="name"/>
                            </li>

                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">

<!--                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','1','123') >充值</a>-->

<!--                onclick=refreshCach(\''+row.roleid+"\',\'1\',\'speak\'"+')-->
<!--                <a style="float: left" class="btn btn-warning refreshCache"  cus-type="maintain" shiro:hasPermission="system:fightdropset:refreshCache">-->
<!--                    <i class="fa fa-download"></i>全踢下线-->
<!--                </a>-->
                <div style="font-size: 23px; margin-left: 20px; float: left">
                    <span style="color:rgb(16 16 16)">在线人数:</span>
                    <span id="countOnline">0</span>
                    <span style="color:rgb(16 16 16)">       </span>
                </div>

                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','1','maintain') >维护</a>
                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','0','maintain') >开服</a>
                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','100','ceshi') >内测</a>
                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','0','ceshi') >公测</a>

                <span style="color:rgb(16 16 16)">区组状态:</span>
                <span id="serverstate">0</span>
                <span style="color:rgb(16 16 16)">测试状态:</span>
                <span id="ceshistate">0</span>



                <span id="ceshistate111">                </span>
                <a class="btn btn-success btn-xs "  onclick=refreshCach('1','100','startKuafu') >开启跨服</a>

                <span id="ceshistate112">                 </span>
                <a class="btn btn-success btn-xs "  onclick=refreshTask() >重置每日任务</a>
<!--               <a class="btn btn-success btn-xs "  onclick=refreshCach('1','1','delall') >删档</a>-->
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('system:accountrole:edit')}]];
        var removeFlag = [[${@permission.hasPermi('system:accountrole:remove')}]];
        var prefix = ctx + "system/accountrole";
        var prehost = ctx;
        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "角色管理",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'roleid', 
                    title: '角色ID',
                    visible: false
                },
                {
                    field: 'name', 
                    title: '角色名'
                },
                {
                    field: 'money', 
                    title: '金币'
                },
                {
                    field: 'level', 
                    title: '等级'
                },
                {
                    field: 'createtime', 
                    title: '创建时间'
                },
                {
                    field: 'bantrade', 
                    title: '禁止交易',
                    formatter: function(value, row, index) {
                        if (row.bantrade == 1) {
                            return "是";
                        }
                        return "否";
                    }
                },
                {
                    field: 'gender', 
                    title: '性别',
                    formatter: function(value, row, index) {
                        if (row.gender == 1) {
                            return "男";
                        }
                        return "女";
                    }
                },
                {
                    field: 'stallcash', 
                    title: '摆摊收入'
                },
                {
                    field: 'stallgold', 
                    title: '珍宝收入'
                },
                {
                    field: 'storemoney', 
                    title: '仓库存钱'
                },
                {
                    field: 'pos',
                    title: '所在地图ID',
                    formatter: function(value, row, index) {
                        var obj=eval("("+row.pos+")");
                        return obj.mapId;
                    }
                },
                {
                    field: 'locktime', 
                    title: '封号结束时间',
                    formatter: function(value, row, index) {
                        if (row.locktime != 0) {
                            return new Date(parseInt(row.locktime)).toLocaleString().replace(/:\d{1,2}$/,' ');
                        }
                        return row.locktime;
                    }
                },
                {
                    field: 'wordtime',
                    title: '禁言结束时间',
                    formatter: function(value, row, index) {
                        if (row.wordtime != 0) {
                            return new Date(parseInt(row.wordtime)).toLocaleString().replace(/:\d{1,2}$/,' ');
                        }
                        return row.wordtime;
                    }
                },
                {
                    field: 'onLine', 
                    title: '在线状态',
                    formatter: function(value, row, index) {
                        if (row.onLine == 1) {
                            return "<font color='#009688'>在线</font>";
                        }
                        return "<font color='#ff0000'>不在线</font>";
                    }
                },
                {
                    field: 'rankzhanli', 
                    title: '战力'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        var nowTime = Date.now();
                       // actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleid + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        if(nowTime<row.locktime){
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.roleid+"\',\'1\',\'seal\'"+')>解封</a>');
                        }else{
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.roleid+"\',\'0\',\'seal\'"+')> 封角色</a>');
                        }
                        if(nowTime<row.wordtime){
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.roleid+"\',\'1\',\'speak\'"+') >解禁</a>');
                        }else{
                            actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.roleid+"\',\'0\',\'speak\'"+') >禁言</a>');
                        }
                        actions.push(' <a class="btn btn-success btn-xs "  onclick=refreshCach(\''+row.roleid+"\',\'0\',\'killPlayers\'"+')>踢下线</a>');

                        actions.push(' <a class="btn btn-success btn-xs "  onclick=getAccount(\''+row.sid+"\',\'0\',\'killPlayers\'"+')>查看账号</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
<script>
    var countUrl = prefix+"/countOnline";
    var config = {
        url: countUrl,
        type: "post",
        dataType: "json",
        success: function(result) {
            if(result.data.gate == 1){
                $("#serverstate").html("维护")
            }else{
                $("#serverstate").html("开服")
            }
            if(result.data.neice == 0){
                $("#ceshistate").html("公测")
            }else{
                $("#ceshistate").html("内测")

            }
            $("#countOnline").html(result.data.onlineRoles)
        }
    };
    $.ajax(config)


    function refreshCach (name,state,type) {

        var url = prehost+"system/cacheManage/refreshCache";
        // 保存信息 刷新表格
        var config = {
            url: url,
            type: "post",
            dataType: "json",
            data: {"type":type,"value":name,"state":state},
            beforeSend: function () {
                $.modal.loading("正在处理中，请稍后...");
            },
            success: function(result) {
                if (typeof callback == "function") {
                    callback(result);
                }
                $.operate.ajaxSuccess(result);
            }
        };
        $.ajax(config)


        var config2 = {
            url: countUrl,
            type: "post",
            dataType: "json",
            success: function(result) {
                if(result.data.gate == 1){
                    $("#serverstate").html("维护")
                }else{
                    $("#serverstate").html("开服")
                }
                if(result.data.neice == 0){
                    $("#ceshistate").html("公测")
                }else{
                    $("#ceshistate").html("内测")

                }
                $("#countOnline").html(result.data.onlineRoles)
            }
        };
        $.ajax(config2)

    }
    function getAccount (name,state,type) {
        var countUrl = prefix+"/queryAccount";
        var config3 = {
            url: countUrl,
            type: "post",
            dataType: "json",
            data: {"type":type,"roleId":name,"state":state},
            success: function(result) {
                alert(result.data);
            }
        };
        $.ajax(config3)
    }

     function refreshTask () {
        var url = prehost+"system/cacheManage/rebootTask";
        var config3 = {
            url: url,
            type: "post",
            dataType: "json",
            data: {},
            success: function(result) {
                alert(result.msg);
            }
        };
        $.ajax(config3)
    }


</script>
</html>